package com.qf.blog.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.blog.dto.CommentDto;
import com.qf.blog.dto.IndexPostDto;
import com.qf.blog.dto.MyPage;
import com.qf.blog.entity.Post;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.blog.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 达哥
 * @since 2023-03-24
 */
public interface PostMapper extends BaseMapper<Post> {
    public MyPage<IndexPostDto> indexPostDataPageVo(@Param("page") IPage<IndexPostDto> page, @Param("orderMode") Integer orderMode);

    IndexPostDto info(Integer id);

    List<CommentDto> getCommentListByPostId(Integer id);

    @Update("update t_discuss_post set score = #{source} where id = #{postId}")
    void updatePostSource(@Param("postId") Integer postId, @Param("source") double source);

    List<IndexPostDto> adminPostList();

    @Update("update t_discuss_post set type = #{type} where id = #{id}")
    Integer updatePostType(@Param("id") Integer id, @Param("type") Integer type);
}
